package com.xiaoy.core.basic.security.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.xiaoy.util.store.config.ConfigTable;


@Entity
@Table(name = ConfigTable.Basic.SECURITY_PARTYROLE)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(sequenceName = ConfigTable.Basic.SECURITY_PARTYROLE+"_SEQ", name = ConfigTable.Basic.SECURITY_PARTYROLE+"_SEQ", allocationSize = 1)
public class RoleType {

	
	private long id;
	private List<Role>roles = new ArrayList<Role>();
	private String name;
	private long sort;
	
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = ConfigTable.Basic.SECURITY_PARTYROLE+"_SEQ")
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "type")
	@Fetch(FetchMode.SUBSELECT)
	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getSort() {
		return sort;
	}

	public void setSort(long sort) {
		this.sort = sort;
	}
}
